﻿#define  _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main()
{
	int arr[10] = { 1,2,3,4,5,6,7,8,9,10 };
	int key = 7;
	int sz = sizeof(arr) / sizeof(arr[0]);
	int left = 0;
	int fight = sz - 1;
	while (left <= fight)
	{
		int mid = (left + fight) / 2;
		if (arr[mid] > key)
		{
			fight = mid - 1;
		}
		else if (arr[mid] < key)
		{
			left = mid + 1;
		}
		else
		{
			printf("找到了下标是:%d\n", mid);
			break;
		}
	}
	return 0;
}

